package org.dtrevien.ihm;

import java.awt.Cursor;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;

public class MouseLsn implements MouseMotionListener, MouseListener {

	protected MainFrame f;
	private int x     = 0;   // x coord - set from drag
    private int y     = 0;   // y coord - set from drag
	private int x1;
	private int y1;
	private int x2;
	private int y2;
    
	public MouseLsn(final MainFrame f) {
		this.f = f;
	}
	
	
	@Override
	public void mouseDragged(MouseEvent e) {
		this.x2 = e.getX();
        this.y2 = e.getY();
        this.x = this.x + this.x2 - this.x1;
        this.y = this.y + this.y2 - this.y1;
        this.x1 = this.x2;
        this.y1 = this.y2;
		
		this.f.imagePanel.setImagePosition(this.x, this.y);
		
		this.f.setCursor(new Cursor(Cursor.HAND_CURSOR));
	}

	@Override
	public void mouseMoved(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}


	@Override
	public void mouseClicked(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}


	@Override
	public void mouseEntered(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}


	@Override
	public void mouseExited(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}


	@Override
	public void mousePressed(MouseEvent e) {
		this.x1 = e.getX();
        this.y1 = e.getY();
	}


	@Override
	public void mouseReleased(MouseEvent e) {
		this.f.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
	}

}
